package cc.kzc.adminauth.auth.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson2.JSONObject;

import cc.kzc.adminauth.common.BaseResponse;
import cc.kzc.adminauth.misc.HttpRequestUtil;
import lombok.extern.slf4j.Slf4j;

@Validated
@Controller
@Slf4j
public class HelloController {

	@Autowired
	private HttpServletRequest request;

	@RequestMapping(value = { "/hello" }, produces = "application/json;charset=UTF-8")
	@ResponseBody()
	public String hello() {

		String ip = HttpRequestUtil.getIpAddr(request);
		log.debug("[/hello]-->[{}]", ip);

		BaseResponse resp = BaseResponse.success();
		resp.setResult("admin auth say: hello!");

		String ret = JSONObject.toJSONString(resp);
		log.debug(ret);
		return ret;
	}

}
